<?php

    header('Access-Control-Allow-Origin: *');
	header("Access-Control-Allow-Method:POST,GET");
    header ( "Content-Type: text/html; charset=UTF-8" );
    //header("Content-Type: application/json;charset=utf-8");
    require_once 'mysql.function.php';
	require_once 'response.class.php';

	//$rawPostData = file_get_contents("php://input");
	//$postData = json_decode($rawPostData,true);
	//$name = $postData['name'];
    $name= $_POST["name"];

    if(empty($name)){
		$message = array(
			'content'=>'提交的内容不能为空~',		
		);
		$re = new Response();
		$re->show(200,'fail',$message);
	}

    $sqlhelper = new sqlhelper();
    $array = array('name'=>$name);
	$table = "test_name";
	$affectedRows = $sqlhelper->insert($table,$array);
	$sqlhelper->close_connect();

	$re = new Response();
	if($affectedRows > 0){
		$message = array(
			'content'=>'提交数据成功',
		);
		$re->show(200,'success',$message);
	}else{
		$message = array(
			'content'=>'提交数据失败,请@留言,联系公众号~',
		);
		$re->show(200,'fail',$message);
	}
	exit();
